import VueRouter from 'vue-router'
import Home from "../views/Home";
import User from "../views/User";
import Main from "../views/Main";
import Mall from "../views/Mall";
import PageOne from "@/views/PageOne";
import PageTwo from "@/views/PageTwo";

import Vue from "vue";
Vue.use(VueRouter)
//创建路由组件
//将组件和路由进行映射
const routes = [
    //主路由
    {
        path: '/',
        component: Main,
        redirect:'/home',//当path是/时重定向
        children:[
            //子路由 嵌套路由
            { path: '/home', component: Home },
            { path: '/user', component: User },
            { path: '/mall', component: Mall },
            { path: '/page1', component: PageOne },
            { path: '/page2', component: PageTwo }
        ]
    }

]
//创建router实例
const router = new VueRouter({
    routes // (缩写) 相当于 routes: routes
})

export default router
